<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: SNRThresholdDecider Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00203.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">SNRThresholdDecider Class Reference<div class="ingroups"><a class="el" href="a00512.html">decider - decider modules</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="SNRThresholdDecider" --><!-- doxytag: inherits="BaseDecider" -->
<p><a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> implementation which decides a signals correctness by checking its SNR against a threshold.  
 <a href="a00203.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00481_source.html">SNRThresholdDecider.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for SNRThresholdDecider:</div>
<div class="dyncontent">
<div class="center"><img src="a01024.png" border="0" usemap="#SNRThresholdDecider_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for SNRThresholdDecider:</div>
<div class="dyncontent">
<div class="center"><img src="a01025.png" border="0" usemap="#SNRThresholdDecider_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a01026.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00203.html#aad17421c20bd89d6670ab110558a2479">SNRThresholdDecider</a> (<a class="el" href="a00079.html">DeciderToPhyInterface</a> *<a class="el" href="a00070.html#ac0f72556cb799d883b4219cab58320bb">phy</a>, double <a class="el" href="a00020.html#a5eece8bf532f92912ccbd0a3bc4d6fb0">sensitivity</a>, int <a class="el" href="a00020.html#a33e7f02028e78116193d09d6cdbc987e">myIndex</a>=-1, bool <a class="el" href="a00020.html#aa22cd5156240713e37578172ba5557ce">debug</a>=false)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes a new <a class="el" href="a00203.html" title="Decider implementation which decides a signals correctness by checking its SNR against a threshold...">SNRThresholdDecider</a>.  <a href="#aad17421c20bd89d6670ab110558a2479"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00203.html#a52492077116fc26bc18f97bc94565800">initFromMap</a> (const <a class="el" href="a00070.html#a7f3ee545f2ae8b0d8d1814c98917f5b6">ParameterMap</a> &amp;params)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the decider from XML map data.  <a href="#a52492077116fc26bc18f97bc94565800"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="a00044.html">ChannelState</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00203.html#aa777b8c29fabf14d30d03972fed515d0">getChannelState</a> () const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">A function that returns information about the channel state.  <a href="#aa777b8c29fabf14d30d03972fed515d0"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00203.html#abb6ae13f91f830a9e6cd975426b9d6df">checkIfAboveThreshold</a> (<a class="el" href="a00136.html">Mapping</a> *map, simtime_t_cref start, simtime_t_cref end) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks a mapping against a specific threshold (element-wise).  <a href="#abb6ae13f91f830a9e6cd975426b9d6df"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="a00075.html">DeciderResult</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00203.html#ac75875c691493cd4c69a01f3aeb6cd22">createResult</a> (const <a class="el" href="a00070.html#a8532046253d31801ffe4bc56b0d70850">airframe_ptr_t</a> frame) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Processes a received AirFrame.  <a href="#ac75875c691493cd4c69a01f3aeb6cd22"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae38586c5255f37cfe67aa1bdec283dde"></a><!-- doxytag: member="SNRThresholdDecider::canAnswerCSR" ref="ae38586c5255f37cfe67aa1bdec283dde" args="(const CSRInfo &amp;requestInfo) const " -->
virtual simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00203.html#ae38586c5255f37cfe67aa1bdec283dde">canAnswerCSR</a> (const <a class="el" href="a00020.html#a2b6737edc0aa4a9c90f2da7b090caf76">CSRInfo</a> &amp;requestInfo) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns point in time when the ChannelSenseRequest of the passed CSRInfo can be answered (e.g. because channel state changed or timeout is reached). <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00203.html#aa7e33361b328274b04ff7bd2d6206e6d">answerCSR</a> (<a class="el" href="a00020.html#a2b6737edc0aa4a9c90f2da7b090caf76">CSRInfo</a> &amp;requestInfo)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Answers the ChannelSenseRequest (CSR) from the passed CSRInfo.  <a href="#aa7e33361b328274b04ff7bd2d6206e6d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00203.html#ae900f58c344f86cea2dbf21b55a74d85">isIdleRSSI</a> (double rssi) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns whether the passed rssi value indicates a idle channel.  <a href="#ae900f58c344f86cea2dbf21b55a74d85"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abdb6b19743460a19e900c4b6d38c483b"></a><!-- doxytag: member="SNRThresholdDecider::snrThreshold" ref="abdb6b19743460a19e900c4b6d38c483b" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b">snrThreshold</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Threshold value for checking a SNR-map (SNR-threshold). <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8f32acd24c8c84efee941211d1f81c98"></a><!-- doxytag: member="SNRThresholdDecider::busyThreshold" ref="a8f32acd24c8c84efee941211d1f81c98" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00203.html#a8f32acd24c8c84efee941211d1f81c98">busyThreshold</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The threshold rssi level above which the channel is considered busy. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p><a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> implementation which decides a signals correctness by checking its SNR against a threshold. </p>
<p><a class="el" href="a00203.html" title="Decider implementation which decides a signals correctness by checking its SNR against a threshold...">SNRThresholdDecider</a> decides the channel state (idle/busy) at hand of the current received total power level (independent from signal or noise). If its above the threshold defined by the "busyThreshold" parameter it considers the channel busy. The RSSI value returned by this <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> for a ChannelSenseRequest over time is always the RSSI value at the end of the sense.</p>
<p><a class="el" href="a00203.html" title="Decider implementation which decides a signals correctness by checking its SNR against a threshold...">SNRThresholdDecider</a> implements only instantaneous channel sensing therefore it can only handle "UNTIL_IDLE" and "UNTIL_BUSY" ChannelSenseRequests but not "UNTIL_TIMEOUT".</p>
<p>Instantaneous channel sensing means <a class="el" href="a00203.html" title="Decider implementation which decides a signals correctness by checking its SNR against a threshold...">SNRThresholdDecider</a> is simplified in the way that the channel does not has to be below the threshold for a certain amount of time to be considered idle (how it would be in reality), but immediately after the RSSI drops below the threshold the channel is considered idle. This means "UNTIL_IDLE" and "UNTIL_BUSY" request are also answered at the first moment the channel drops below or raises above the threshold. <a class="el" href="a00203.html" title="Decider implementation which decides a signals correctness by checking its SNR against a threshold...">SNRThresholdDecider</a> does not support "UNTIL_TIMEOUT" requests because they are used to calculate the channel state over a time period (by averaging over it for example) which is not consistent with using instantaneous idle/busy changes. </p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="aad17421c20bd89d6670ab110558a2479"></a><!-- doxytag: member="SNRThresholdDecider::SNRThresholdDecider" ref="aad17421c20bd89d6670ab110558a2479" args="(DeciderToPhyInterface *phy, double sensitivity, int myIndex=&#45;1, bool debug=false)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">SNRThresholdDecider::SNRThresholdDecider </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00079.html">DeciderToPhyInterface</a> *&#160;</td>
          <td class="paramname"><em>phy</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>sensitivity</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>myIndex</em> = <code>-1</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>debug</em> = <code>false</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initializes a new <a class="el" href="a00203.html" title="Decider implementation which decides a signals correctness by checking its SNR against a threshold...">SNRThresholdDecider</a>. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">phy</td><td>- pointer to the deciders phy layer </td></tr>
    <tr><td class="paramname">snrThreshold</td><td>- the threshold (as fraction) above which a signal is received correctly </td></tr>
    <tr><td class="paramname">sensitivity</td><td>- the sensitivity (in mW) of the physical layer </td></tr>
    <tr><td class="paramname">busyThreshold</td><td>- the rssi threshold (in mW) above which the channel is considered idle </td></tr>
    <tr><td class="paramname">myIndex</td><td>- the index of the host of this deciders phy (for debugging output) </td></tr>
    <tr><td class="paramname">debug</td><td>- should debug messages be displayed? </td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment">    : <a class="code" href="a00020.html#acff4618fa7a9c2e9abf257e60e487de2" title="Initializes the decider with the passed values.">BaseDecider</a>(phy, <a class="code" href="a00020.html#a5eece8bf532f92912ccbd0a3bc4d6fb0" title="Sensitivity value for receiving an AirFrame if it &lt;= 0 then no sensitivity check will be done...">sensitivity</a>, <a class="code" href="a00020.html#a33e7f02028e78116193d09d6cdbc987e" title="index for this Decider-instance given by Phy-Layer (mostly Host-index)">myIndex</a>, <a class="code" href="a00020.html#aa22cd5156240713e37578172ba5557ce" title="toggles display of debugging messages">debug</a>)
    , <a class="code" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b" title="Threshold value for checking a SNR-map (SNR-threshold).">snrThreshold</a>(0)
    , <a class="code" href="a00203.html#a8f32acd24c8c84efee941211d1f81c98" title="The threshold rssi level above which the channel is considered busy.">busyThreshold</a>(<a class="code" href="a00020.html#a5eece8bf532f92912ccbd0a3bc4d6fb0" title="Sensitivity value for receiving an AirFrame if it &lt;= 0 then no sensitivity check will be done...">sensitivity</a>)
  {}
</pre></div>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aa7e33361b328274b04ff7bd2d6206e6d"></a><!-- doxytag: member="SNRThresholdDecider::answerCSR" ref="aa7e33361b328274b04ff7bd2d6206e6d" args="(CSRInfo &amp;requestInfo)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void SNRThresholdDecider::answerCSR </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00020.html#a2b6737edc0aa4a9c90f2da7b090caf76">CSRInfo</a> &amp;&#160;</td>
          <td class="paramname"><em>requestInfo</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Answers the ChannelSenseRequest (CSR) from the passed CSRInfo. </p>
<p>Calculates the rssi value and the channel idle state and sends the CSR together with the result back to the mac layer. </p>

<p>Reimplemented from <a class="el" href="a00020.html#ab8e925001d1f8630338c50f8ec10bb0d">BaseDecider</a>.</p>

<p>References <a class="el" href="a00203.html#aa777b8c29fabf14d30d03972fed515d0">getChannelState()</a>, <a class="el" href="a00070.html#ac0f72556cb799d883b4219cab58320bb">Decider::phy</a>, and <a class="el" href="a00079.html#a319e413b963f03ff218b0d0024fb66b9">DeciderToPhyInterface::sendControlMsgToMac()</a>.</p>
<div class="fragment"><pre class="fragment">{
  <span class="comment">// put the sensing-result to the request and</span>
  <span class="comment">// send it to the Mac-Layer as Control-message (via Interface)</span>
  requestInfo.getRequest()-&gt;setResult( <a class="code" href="a00203.html#aa777b8c29fabf14d30d03972fed515d0" title="A function that returns information about the channel state.">getChannelState</a>() );
  <a class="code" href="a00070.html#ac0f72556cb799d883b4219cab58320bb" title="A pointer to the physical layer of this Decider.">phy</a>-&gt;<a class="code" href="a00079.html#a319e413b963f03ff218b0d0024fb66b9" title="Called by the Decider to send a control message to the MACLayer.">sendControlMsgToMac</a>(requestInfo.getRequest());

  requestInfo.clear();
}
</pre></div>
</div>
</div>
<a class="anchor" id="abb6ae13f91f830a9e6cd975426b9d6df"></a><!-- doxytag: member="SNRThresholdDecider::checkIfAboveThreshold" ref="abb6ae13f91f830a9e6cd975426b9d6df" args="(Mapping *map, simtime_t_cref start, simtime_t_cref end) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool SNRThresholdDecider::checkIfAboveThreshold </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00136.html">Mapping</a> *&#160;</td>
          <td class="paramname"><em>map</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">simtime_t_cref&#160;</td>
          <td class="paramname"><em>start</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">simtime_t_cref&#160;</td>
          <td class="paramname"><em>end</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Checks a mapping against a specific threshold (element-wise). </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>true , if every entry of the mapping is above threshold false , otherwise </dd></dl>

<p>References <a class="el" href="a00136.html#acdf62aed4b8a469e63c036e75567c2e3">Mapping::createConstIterator()</a>, <a class="el" href="a00020.html#aa22cd5156240713e37578172ba5557ce">BaseDecider::debug</a>, <a class="el" href="a00059.html#a1f4cae3b170754a76049b8e81b2e3c07">ConstMappingIterator::getNextPosition()</a>, <a class="el" href="a00059.html#a047e853613d5a19ff34526d0cff8fcf9">ConstMappingIterator::getPosition()</a>, <a class="el" href="a00013.html#a2ecb3b041b5b8721d6767531e4ac792a">Argument::getTime()</a>, <a class="el" href="a00059.html#ad4419c259e747867f003d07d62d4259f">ConstMappingIterator::getValue()</a>, <a class="el" href="a00059.html#ad4bac7233c154b7086c6124d2e21be49">ConstMappingIterator::hasNext()</a>, <a class="el" href="a00059.html#a607d741e2d841265851a85670f247c46">ConstMappingIterator::iterateTo()</a>, <a class="el" href="a00059.html#afdafa6870cd19b3d35674a7bc777585d">ConstMappingIterator::next()</a>, and <a class="el" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b">snrThreshold</a>.</p>

<p>Referenced by <a class="el" href="a00203.html#ac75875c691493cd4c69a01f3aeb6cd22">createResult()</a>.</p>
<div class="fragment"><pre class="fragment">{
  assert(map);

  <span class="keywordflow">if</span>(<a class="code" href="a00020.html#aa22cd5156240713e37578172ba5557ce" title="toggles display of debugging messages">debug</a>){
    deciderEV &lt;&lt; <span class="stringliteral">&quot;Checking if SNR is above Threshold of &quot;</span> &lt;&lt; <a class="code" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b" title="Threshold value for checking a SNR-map (SNR-threshold).">snrThreshold</a> &lt;&lt; endl;
  }

  <span class="comment">// check every entry in the mapping against threshold value</span>
  <a class="code" href="a00059.html" title="Defines an const iterator for a ConstMapping which is able to iterate over the Mapping.">ConstMappingIterator</a>* it = map-&gt;<a class="code" href="a00136.html#acdf62aed4b8a469e63c036e75567c2e3" title="Returns an ConstMappingIterator by use of the respective implementation of the &quot;createIterator()&quot;-met...">createConstIterator</a>(<a class="code" href="a00013.html" title="Defines an argument for a mapping.">Argument</a>(start));
  <span class="comment">// check if values at start-time fulfill snrThreshold-criterion</span>
  <span class="keywordflow">if</span>(<a class="code" href="a00020.html#aa22cd5156240713e37578172ba5557ce" title="toggles display of debugging messages">debug</a>){
    deciderEV &lt;&lt; <span class="stringliteral">&quot;SNR at time &quot;</span> &lt;&lt; start &lt;&lt; <span class="stringliteral">&quot; is &quot;</span> &lt;&lt; it-&gt;<a class="code" href="a00059.html#ad4419c259e747867f003d07d62d4259f" title="Returns the value of the Mapping at the current position.">getValue</a>() &lt;&lt; endl;
  }
  <span class="keywordflow">if</span> ( it-&gt;<a class="code" href="a00059.html#ad4419c259e747867f003d07d62d4259f" title="Returns the value of the Mapping at the current position.">getValue</a>() &lt;= <a class="code" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b" title="Threshold value for checking a SNR-map (SNR-threshold).">snrThreshold</a> ){
    <span class="keyword">delete</span> it;
    <span class="keywordflow">return</span> <span class="keyword">false</span>;
  }

  <span class="keywordflow">while</span> ( it-&gt;<a class="code" href="a00059.html#ad4bac7233c154b7086c6124d2e21be49" title="Returns true if the iterator has a next value it can iterate to on a call to &quot;next()&quot;.">hasNext</a>() &amp;&amp; it-&gt;<a class="code" href="a00059.html#a1f4cae3b170754a76049b8e81b2e3c07" title="Returns the position the next call to &quot;next()&quot; of this Iterator would iterate to.">getNextPosition</a>().<a class="code" href="a00013.html#a2ecb3b041b5b8721d6767531e4ac792a" title="Returns the time value of this argument.">getTime</a>() &lt; end)
  {
    it-&gt;<a class="code" href="a00059.html#afdafa6870cd19b3d35674a7bc777585d" title="Iterates to the next position of the Mapping.">next</a>();

    <span class="keywordflow">if</span>(<a class="code" href="a00020.html#aa22cd5156240713e37578172ba5557ce" title="toggles display of debugging messages">debug</a>){
      deciderEV &lt;&lt; <span class="stringliteral">&quot;SNR at time &quot;</span> &lt;&lt; it-&gt;<a class="code" href="a00059.html#a047e853613d5a19ff34526d0cff8fcf9" title="Returns the current position of the iterator.">getPosition</a>().<a class="code" href="a00013.html#a2ecb3b041b5b8721d6767531e4ac792a" title="Returns the time value of this argument.">getTime</a>() &lt;&lt; <span class="stringliteral">&quot; is &quot;</span> &lt;&lt; it-&gt;<a class="code" href="a00059.html#ad4419c259e747867f003d07d62d4259f" title="Returns the value of the Mapping at the current position.">getValue</a>() &lt;&lt; endl;
    }

    <span class="comment">// perform the check for smaller entry</span>
    <span class="keywordflow">if</span> ( it-&gt;<a class="code" href="a00059.html#ad4419c259e747867f003d07d62d4259f" title="Returns the value of the Mapping at the current position.">getValue</a>() &lt;= <a class="code" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b" title="Threshold value for checking a SNR-map (SNR-threshold).">snrThreshold</a>) {
      <span class="keyword">delete</span> it;
      <span class="keywordflow">return</span> <span class="keyword">false</span>;
    }
  }

  it-&gt;<a class="code" href="a00059.html#a607d741e2d841265851a85670f247c46" title="Iterates to the specified position. This method should be used if the new position is near the curren...">iterateTo</a>(<a class="code" href="a00013.html" title="Defines an argument for a mapping.">Argument</a>(end));
  <span class="keywordflow">if</span>(<a class="code" href="a00020.html#aa22cd5156240713e37578172ba5557ce" title="toggles display of debugging messages">debug</a>){
    deciderEV &lt;&lt; <span class="stringliteral">&quot;SNR at time &quot;</span> &lt;&lt; end &lt;&lt; <span class="stringliteral">&quot; is &quot;</span> &lt;&lt; it-&gt;<a class="code" href="a00059.html#ad4419c259e747867f003d07d62d4259f" title="Returns the value of the Mapping at the current position.">getValue</a>() &lt;&lt; endl;
  }

  <span class="keywordflow">if</span> ( it-&gt;<a class="code" href="a00059.html#ad4419c259e747867f003d07d62d4259f" title="Returns the value of the Mapping at the current position.">getValue</a>() &lt;= <a class="code" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b" title="Threshold value for checking a SNR-map (SNR-threshold).">snrThreshold</a> ){
    <span class="keyword">delete</span> it;
    <span class="keywordflow">return</span> <span class="keyword">false</span>;
  }

  <span class="keyword">delete</span> it;
  <span class="keywordflow">return</span> <span class="keyword">true</span>;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ac75875c691493cd4c69a01f3aeb6cd22"></a><!-- doxytag: member="SNRThresholdDecider::createResult" ref="ac75875c691493cd4c69a01f3aeb6cd22" args="(const airframe_ptr_t frame) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00075.html">DeciderResult</a> * SNRThresholdDecider::createResult </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00070.html#a8532046253d31801ffe4bc56b0d70850">airframe_ptr_t</a>&#160;</td>
          <td class="paramname"><em>frame</em></td><td>)</td>
          <td> const<code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Processes a received AirFrame. </p>
<p>The SNR-mapping for the <a class="el" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a> is created and checked against the Deciders SNR-threshold. Depending on that the received AirFrame is either sent up to the MAC-Layer or dropped.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>usually return a value for: 'do not pass it again' </dd></dl>

<p>Reimplemented from <a class="el" href="a00020.html#ac6ef3a4cf1b91bcec788b540d61bfeba">BaseDecider</a>.</p>

<p>References <a class="el" href="a00020.html#aea9e98c3a9752bcf08e42742b01d2fe3">BaseDecider::calculateSnrMapping()</a>, <a class="el" href="a00203.html#abb6ae13f91f830a9e6cd975426b9d6df">checkIfAboveThreshold()</a>, <a class="el" href="a00192.html#a2875223239e124d85949e1116cc12ae9">Signal::getReceptionEnd()</a>, <a class="el" href="a00192.html#a7c4710243cf87caf7dfc9f313e2619b2">Signal::getReceptionStart()</a>, <a class="el" href="a00138.html#a31183e79401391df3e2d250846ae8d0e">MappingUtils::post()</a>, <a class="el" href="a00138.html#a2cf7c04c0adea7f6e9fe49101b0197c3">MappingUtils::pre()</a>, and <a class="el" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b">snrThreshold</a>.</p>
<div class="fragment"><pre class="fragment">{
  <span class="comment">// first collect all necessary information</span>
  <a class="code" href="a00136.html" title="Represents a changeable mapping (mathematical function) from at least time to Argument::mapped_type.">Mapping</a>* snrMap = <a class="code" href="a00020.html#aea9e98c3a9752bcf08e42742b01d2fe3" title="Calculates a SNR-Mapping for a Signal.">calculateSnrMapping</a>(frame);
  assert(snrMap);

  <span class="keyword">const</span> <a class="code" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a>&amp; signal = frame-&gt;getSignal();

  <span class="comment">// NOTE: Since this decider does not consider the amount of time when the signal&#39;s SNR is</span>
  <span class="comment">// below the threshold even the smallest (normally insignificant) drop causes this decider</span>
  <span class="comment">// to reject reception of the signal.</span>
  <span class="comment">// Since the default MiXiM-signal is still zero at its exact start and end, these points</span>
  <span class="comment">// are ignored in the interval passed to the following method.</span>
  <span class="keywordtype">bool</span> aboveThreshold = <a class="code" href="a00203.html#abb6ae13f91f830a9e6cd975426b9d6df" title="Checks a mapping against a specific threshold (element-wise).">checkIfAboveThreshold</a>(snrMap,
                                              <a class="code" href="a00138.html#a31183e79401391df3e2d250846ae8d0e" title="returns the closest value of simtime after passed values">MappingUtils::post</a>(signal.<a class="code" href="a00192.html#a7c4710243cf87caf7dfc9f313e2619b2" title="Returns the point in time when the receiving of the Signal started at the receiver module...">getReceptionStart</a>()),
                                              <a class="code" href="a00138.html#a2cf7c04c0adea7f6e9fe49101b0197c3" title="returns the closest value of simtime before passed value">MappingUtils::pre</a>(signal.<a class="code" href="a00192.html#a2875223239e124d85949e1116cc12ae9" title="Returns the point in time when the receiving of the Signal ended at the receiver module. Already includes the propagation delay.">getReceptionEnd</a>()));

  <span class="keyword">delete</span> snrMap; snrMap = NULL;

  <span class="comment">// check if the snrMapping is above the Decider&#39;s specific threshold,</span>
  <span class="comment">// i.e. the Decider has received it correctly</span>
  <span class="keywordflow">if</span> (aboveThreshold) {
    deciderEV &lt;&lt; <span class="stringliteral">&quot;SNR is above threshold(&quot;</span>&lt;&lt;<a class="code" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b" title="Threshold value for checking a SNR-map (SNR-threshold).">snrThreshold</a>&lt;&lt;<span class="stringliteral">&quot;) -&gt; sending up.&quot;</span> &lt;&lt; endl;
  }
  <span class="keywordflow">else</span> {
    deciderEV &lt;&lt; <span class="stringliteral">&quot;SNR is below threshold(&quot;</span>&lt;&lt;<a class="code" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b" title="Threshold value for checking a SNR-map (SNR-threshold).">snrThreshold</a>&lt;&lt;<span class="stringliteral">&quot;) -&gt; dropped.&quot;</span> &lt;&lt; endl;
  }

  <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="a00075.html" title="A class to represent the result of a processed packet (that is not noise) by the Decider.">DeciderResult</a>(aboveThreshold &amp;&amp; !frame-&gt;hasBitError());
}
</pre></div>
</div>
</div>
<a class="anchor" id="aa777b8c29fabf14d30d03972fed515d0"></a><!-- doxytag: member="SNRThresholdDecider::getChannelState" ref="aa777b8c29fabf14d30d03972fed515d0" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00044.html">ChannelState</a> SNRThresholdDecider::getChannelState </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>A function that returns information about the channel state. </p>
<p>It is an alternative for the MACLayer in order to obtain information immediately (in contrast to sending a ChannelSenseRequest, i.e. sending a cMessage over the OMNeT-control-channel) </p>

<p>Reimplemented from <a class="el" href="a00020.html#a35e3f8f4e683747fbec1618ee1608982">BaseDecider</a>.</p>

<p>References <a class="el" href="a00044.html#a74ccec73c5ab45677575e568d3a455fa">ChannelState::getRSSI()</a>, and <a class="el" href="a00203.html#ae900f58c344f86cea2dbf21b55a74d85">isIdleRSSI()</a>.</p>

<p>Referenced by <a class="el" href="a00203.html#aa7e33361b328274b04ff7bd2d6206e6d">answerCSR()</a>.</p>
<div class="fragment"><pre class="fragment">{
  <a class="code" href="a00044.html" title="Provides information about the current state of the channel:">ChannelState</a> csBase = <a class="code" href="a00203.html#aa777b8c29fabf14d30d03972fed515d0" title="A function that returns information about the channel state.">BaseDecider::getChannelState</a>();

  <span class="keywordflow">return</span> <a class="code" href="a00044.html" title="Provides information about the current state of the channel:">ChannelState</a>(<span class="comment">/*csBase.isIdle() &amp;&amp;*/</span> <a class="code" href="a00203.html#ae900f58c344f86cea2dbf21b55a74d85" title="Returns whether the passed rssi value indicates a idle channel.">isIdleRSSI</a>(csBase.<a class="code" href="a00044.html#a74ccec73c5ab45677575e568d3a455fa" title="Returns the current RSSI value of the channel.">getRSSI</a>()), csBase.<a class="code" href="a00044.html#a74ccec73c5ab45677575e568d3a455fa" title="Returns the current RSSI value of the channel.">getRSSI</a>());
}
</pre></div>
</div>
</div>
<a class="anchor" id="a52492077116fc26bc18f97bc94565800"></a><!-- doxytag: member="SNRThresholdDecider::initFromMap" ref="a52492077116fc26bc18f97bc94565800" args="(const ParameterMap &amp;params)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool SNRThresholdDecider::initFromMap </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00070.html#a7f3ee545f2ae8b0d8d1814c98917f5b6">ParameterMap</a> &amp;&#160;</td>
          <td class="paramname"><em>params</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initialize the decider from XML map data. </p>
<p>This method should be defined for generic decider initialization.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">params</td><td>The parameter map which was filled by XML reader.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if the initialization was successfully. </dd></dl>

<p>Reimplemented from <a class="el" href="a00070.html#ae19a201633e5b2bf2d545921049b4f26">Decider</a>.</p>

<p>References <a class="el" href="a00203.html#a8f32acd24c8c84efee941211d1f81c98">busyThreshold</a>, and <a class="el" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b">snrThreshold</a>.</p>
<div class="fragment"><pre class="fragment">                                                                {
    ParameterMap::const_iterator it           = params.find(<span class="stringliteral">&quot;snrThreshold&quot;</span>);
    <span class="keywordtype">bool</span>                         bInitSuccess = <span class="keyword">true</span>;
    <span class="keywordflow">if</span> (it != params.end()) {
        <a class="code" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b" title="Threshold value for checking a SNR-map (SNR-threshold).">snrThreshold</a> = ParameterMap::mapped_type(it-&gt;second).doubleValue();
    }
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((it = params.find(<span class="stringliteral">&quot;threshold&quot;</span>)) != params.end()) {
        <a class="code" href="a00203.html#abdb6b19743460a19e900c4b6d38c483b" title="Threshold value for checking a SNR-map (SNR-threshold).">snrThreshold</a> = ParameterMap::mapped_type(it-&gt;second).doubleValue();
    }
    <span class="keywordflow">else</span> {
        bInitSuccess = <span class="keyword">false</span>;
        opp_warning(<span class="stringliteral">&quot;No threshold defined in config.xml for Decider80211!&quot;</span>);
    }
    <span class="keywordflow">if</span> ((it = params.find(<span class="stringliteral">&quot;busyThreshold&quot;</span>)) != params.end()) {
        <a class="code" href="a00203.html#a8f32acd24c8c84efee941211d1f81c98" title="The threshold rssi level above which the channel is considered busy.">busyThreshold</a> = ParameterMap::mapped_type(it-&gt;second).doubleValue();
    }
    <span class="keywordflow">else</span> {
        deciderEV &lt;&lt; <span class="stringliteral">&quot;No busy threshold defined for SNRThresholdDecider. Using&quot;</span>
                  &lt;&lt; <span class="stringliteral">&quot; phy layers sensitivity as busy threshold.&quot;</span>      &lt;&lt; endl;
    }
    <span class="keywordflow">return</span> <a class="code" href="a00203.html#a52492077116fc26bc18f97bc94565800" title="Initialize the decider from XML map data.">BaseDecider::initFromMap</a>(params) &amp;&amp; bInitSuccess;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ae900f58c344f86cea2dbf21b55a74d85"></a><!-- doxytag: member="SNRThresholdDecider::isIdleRSSI" ref="ae900f58c344f86cea2dbf21b55a74d85" args="(double rssi) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool SNRThresholdDecider::isIdleRSSI </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>rssi</em></td><td>)</td>
          <td> const<code> [inline, protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns whether the passed rssi value indicates a idle channel. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">rssi</td><td>the channels rssi value to evaluate </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if the channel should be considered idle </dd></dl>

<p>Referenced by <a class="el" href="a00203.html#ae38586c5255f37cfe67aa1bdec283dde">canAnswerCSR()</a>, and <a class="el" href="a00203.html#aa777b8c29fabf14d30d03972fed515d0">getChannelState()</a>.</p>
<div class="fragment"><pre class="fragment">                                     {
    <span class="keywordflow">return</span> rssi &lt;= <a class="code" href="a00203.html#a8f32acd24c8c84efee941211d1f81c98" title="The threshold rssi level above which the channel is considered busy.">busyThreshold</a>;
  }
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/phy/<a class="el" href="a00481_source.html">SNRThresholdDecider.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/phy/SNRThresholdDecider.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00203.html">SNRThresholdDecider</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:33 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
